import datetime

from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy.query import Query as BaseQuery
from sqlalchemy.orm import DeclarativeBase


class Query(BaseQuery):
    def soft_delete(self):
        return self.update({"delete_at": datetime.datetime.now()})

    def logic_all(self):
        return self.filter_by(delete_at=None).all()


class Base(DeclarativeBase):
    pass


db = SQLAlchemy(model_class=Base, query_class=Query)

